﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Burglar.MailingService;

namespace Burglar
{
    public class MessageListener : IMailingCallback
    {
        public PalaceAddHandler OnPalaceAdd;
        public delegate void PalaceAddHandler(object sender, PalaceEventArgs e);


        public PalaceRemoveHandler OnPalaceRemove;
        public delegate void PalaceRemoveHandler(object sender, PalaceEventArgs e);

        public PalaceActivityHandler OnActivity;
        public delegate void PalaceActivityHandler(object sender, PalaceActivityEventArgs e);


        public PalaceBurglarAlertHandler OnBurglarChange;
        public delegate void PalaceBurglarAlertHandler(object sender, InvasionAlertEventArgs e);

        public void PalaceAdded(Palace palace){
            if (OnPalaceAdd!=null)
                OnPalaceAdd(this,new PalaceEventArgs{Palace = palace});
        }

        public void PalaceRemoved(Palace palace){ 
            if (OnPalaceAdd != null)
                OnPalaceRemove(this, new PalaceEventArgs { Palace = palace });
        }

        public void PalaceActivity(PalaceActivity activity){
            if (OnPalaceAdd != null)
                OnActivity(this, new PalaceActivityEventArgs { Activity = activity });
        }

        public void PalaceBurglarAlert(InvasionAlert alert) 
        {
            if (OnBurglarChange != null)
                OnBurglarChange(this, new InvasionAlertEventArgs { Alert = alert });
        }
    }
}
